home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 4 / Macwelt DVD 4.cdr / Entwickler / Mac-OS / oxygen / samples / docbook / xsl / html / table.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-09-09  |  27.1 KB  |  791 lines  |  [□□□□/□□□□]

  1.     table.xsljπ¢tÚπ¢tÚÅÅ?◊<?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3.                 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
  4.                 xmlns:stbl="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Table"
  5.                 xmlns:xtbl="com.nwalsh.xalan.Table"
  6.                 xmlns:lxslt="http://xml.apache.org/xslt"
  7.                 exclude-result-prefixes="doc stbl xtbl lxslt"
  8.                 version='1.0'>
  9.  
  10. <xsl:include href="../common/table.xsl"/>
  11.  
  12. <!-- ********************************************************************
  13.      $Id: table.xsl,v 1.1 2002/05/29 09:55:49 dan Exp $
  14.      ********************************************************************
  15.  
  16.      This file is part of the XSL DocBook Stylesheet distribution.
  17.      See ../README or http://nwalsh.com/docbook/xsl/ for copyright
  18.      and other information.
  19.  
  20.      ******************************************************************** -->
  21.  
  22. <lxslt:component prefix="xtbl"
  23.                  functions="adjustColumnWidths"/>
  24.  
  25. <xsl:template name="empty.table.cell">
  26.   <xsl:param name="colnum" select="0"/>
  27.  
  28.   <xsl:variable name="rowsep">
  29.     <xsl:call-template name="inherited.table.attribute">
  30.       <xsl:with-param name="entry" select="NOT-AN-ELEMENT-NAME"/>
  31.       <xsl:with-param name="colnum" select="$colnum"/>
  32.       <xsl:with-param name="attribute" select="'rowsep'"/>
  33.     </xsl:call-template>
  34.   </xsl:variable>
  35.  
  36.   <xsl:variable name="colsep">
  37.     <xsl:call-template name="inherited.table.attribute">
  38.       <xsl:with-param name="entry" select="NOT-AN-ELEMENT-NAME"/>
  39.       <xsl:with-param name="colnum" select="$colnum"/>
  40.       <xsl:with-param name="attribute" select="'colsep'"/>
  41.     </xsl:call-template>
  42.   </xsl:variable>
  43.  
  44.   <td class="auto-generated">
  45.     <xsl:if test="$table.borders.with.css != 0">
  46.       <xsl:attribute name="style">
  47.         <xsl:if test="$colsep > 0">
  48.           <xsl:call-template name="border">
  49.             <xsl:with-param name="side" select="'right'"/>
  50.           </xsl:call-template>
  51.         </xsl:if>
  52.         <xsl:if test="$rowsep > 0">
  53.           <xsl:call-template name="border">
  54.             <xsl:with-param name="side" select="'bottom'"/>
  55.           </xsl:call-template>
  56.         </xsl:if>
  57.       </xsl:attribute>
  58.     </xsl:if>
  59.     <xsl:text> </xsl:text>
  60.   </td>
  61. </xsl:template>
  62.  
  63. <!-- ==================================================================== -->
  64.  
  65. <xsl:template name="border">
  66.   <xsl:param name="side" select="'left'"/>
  67.   <xsl:param name="padding" select="0"/>
  68.  
  69.   <xsl:text>border-</xsl:text>
  70.   <xsl:value-of select="$side"/>
  71.   <xsl:text>: </xsl:text>
  72.   <xsl:value-of select="$table.border.thickness"/>
  73.   <xsl:text> </xsl:text>
  74.   <xsl:value-of select="$table.border.style"/>
  75.   <xsl:text> </xsl:text>
  76.   <xsl:value-of select="$table.border.color"/>
  77.   <xsl:text>; </xsl:text>
  78. </xsl:template>
  79.  
  80. <!-- ==================================================================== -->
  81.  
  82. <xsl:template match="tgroup">
  83.   <table>
  84.     <xsl:choose>
  85.       <!-- If there's a <?dbhtml table-summary="foo"?> PI, use it for
  86.            the HTML table summary attribute -->
  87.       <xsl:when test="processing-instruction('dbhtml')">
  88.         <xsl:variable name="summary">
  89.           <xsl:call-template name="dbhtml-attribute">
  90.             <xsl:with-param name="pis"
  91.                             select="processing-instruction('dbhtml')[1]"/>
  92.             <xsl:with-param name="attribute" select="'table-summary'"/>
  93.           </xsl:call-template>
  94.         </xsl:variable>
  95.         <xsl:if test="$summary != ''">
  96.           <xsl:attribute name="summary">
  97.             <xsl:value-of select="$summary"/>
  98.           </xsl:attribute>
  99.         </xsl:if>
  100.       </xsl:when>
  101.       <!-- Otherwise, if there's a title, use that -->
  102.       <xsl:when test="../title">
  103.         <xsl:attribute name="summary">
  104.           <xsl:value-of select="string(../title)"/>
  105.         </xsl:attribute>
  106.       </xsl:when>
  107.       <!-- Otherwise, forget the whole idea -->
  108.       <xsl:otherwise><!-- nevermind --></xsl:otherwise>
  109.     </xsl:choose>
  110.  
  111.     <xsl:if test="../@pgwide=1">
  112.       <xsl:attribute name="width">100%</xsl:attribute>
  113.     </xsl:if>
  114.  
  115.     <xsl:choose>
  116.       <xsl:when test="../@frame='none'">
  117.         <xsl:attribute name="border">0</xsl:attribute>
  118.       </xsl:when>
  119.       <xsl:when test="$table.borders.with.css != 0">
  120.         <xsl:attribute name="border">0</xsl:attribute>
  121.         <xsl:choose>
  122.           <xsl:when test="../@frame='topbot' or ../@frame='top'">
  123.             <xsl:attribute name="style">
  124.               <xsl:call-template name="border">
  125.                 <xsl:with-param name="side" select="'top'"/>
  126.               </xsl:call-template>
  127.             </xsl:attribute>
  128.           </xsl:when>
  129.           <xsl:when test="../@frame='sides'">
  130.             <xsl:attribute name="style">
  131.               <xsl:call-template name="border">
  132.                 <xsl:with-param name="side" select="'left'"/>
  133.               </xsl:call-template>
  134.               <xsl:call-template name="border">
  135.                 <xsl:with-param name="side" select="'right'"/>
  136.               </xsl:call-template>
  137.             </xsl:attribute>
  138.           </xsl:when>
  139.         </xsl:choose>
  140.       </xsl:when>
  141.       <xsl:otherwise>
  142.         <xsl:attribute name="border">1</xsl:attribute>
  143.       </xsl:otherwise>
  144.     </xsl:choose>
  145.  
  146.     <xsl:variable name="colgroup">
  147.       <colgroup>
  148.         <xsl:call-template name="generate.colgroup">
  149.           <xsl:with-param name="cols" select="@cols"/>
  150.         </xsl:call-template>
  151.       </colgroup>
  152.     </xsl:variable>
  153.  
  154.     <xsl:variable name="explicit.table.width">
  155.       <xsl:call-template name="dbhtml-attribute">
  156.         <xsl:with-param name="pis"
  157.                         select="../processing-instruction('dbhtml')[1]"/>
  158.         <xsl:with-param name="attribute" select="'table-width'"/>
  159.       </xsl:call-template>
  160.     </xsl:variable>
  161.  
  162.     <xsl:variable name="table.width">
  163.       <xsl:choose>
  164.         <xsl:when test="$explicit.table.width != ''">
  165.           <xsl:value-of select="$explicit.table.width"/>
  166.         </xsl:when>
  167.         <xsl:when test="$default.table.width = ''">
  168.           <xsl:text>100%</xsl:text>
  169.         </xsl:when>
  170.         <xsl:otherwise>
  171.           <xsl:value-of select="$default.table.width"/>
  172.         </xsl:otherwise>
  173.       </xsl:choose>
  174.     </xsl:variable>
  175.  
  176.     <xsl:if test="$default.table.width != ''
  177.                   or $explicit.table.width != ''">
  178.       <xsl:attribute name="width">
  179.         <xsl:choose>
  180.           <xsl:when test="contains($table.width, '%')">
  181.             <xsl:value-of select="$table.width"/>
  182.           </xsl:when>
  183.           <xsl:when test="$use.extensions != 0
  184.                           and $tablecolumns.extension != 0">
  185.             <xsl:choose>
  186.               <xsl:when test="function-available('stbl:convertLength')">
  187.                 <xsl:value-of select="stbl:convertLength($table.width)"/>
  188.               </xsl:when>
  189.               <xsl:when test="function-available('xtbl:convertLength')">
  190.                 <xsl:value-of select="xtbl:convertLength($table.width)"/>
  191.               </xsl:when>
  192.               <xsl:otherwise>
  193.                 <xsl:message terminate="yes">
  194.                   <xsl:text>No convertLength function available.</xsl:text>
  195.                 </xsl:message>
  196.               </xsl:otherwise>
  197.             </xsl:choose>
  198.           </xsl:when>
  199.           <xsl:otherwise>
  200.             <xsl:value-of select="$table.width"/>
  201.           </xsl:otherwise>
  202.         </xsl:choose>
  203.       </xsl:attribute>
  204.     </xsl:if>
  205.  
  206.     <xsl:choose>
  207.       <xsl:when test="$use.extensions != 0
  208.                       and $tablecolumns.extension != 0">
  209.         <xsl:choose>
  210.           <xsl:when test="function-available('stbl:adjustColumnWidths')">
  211.             <xsl:copy-of select="stbl:adjustColumnWidths($colgroup)"/>
  212.           </xsl:when>
  213.           <xsl:when test="function-available('xtbl:adjustColumnWidths')">
  214.             <xsl:copy-of select="xtbl:adjustColumnWidths($colgroup)"/>
  215.           </xsl:when>
  216.           <xsl:otherwise>
  217.             <xsl:message terminate="yes">
  218.               <xsl:text>No adjustColumnWidths function available.</xsl:text>
  219.             </xsl:message>
  220.           </xsl:otherwise>
  221.         </xsl:choose>
  222.       </xsl:when>
  223.       <xsl:otherwise>
  224.         <xsl:copy-of select="$colgroup"/>
  225.       </xsl:otherwise>
  226.     </xsl:choose>
  227.  
  228.     <xsl:apply-templates select="thead"/>
  229.     <xsl:apply-templates select="tfoot"/>
  230.     <xsl:apply-templates select="tbody"/>
  231.  
  232.     <xsl:if test=".//footnote">
  233.       <tbody class="footnotes">
  234.         <tr>
  235.           <td colspan="{@cols}">
  236.             <xsl:apply-templates select=".//footnote" mode="table.footnote.mode"/>
  237.           </td>
  238.         </tr>
  239.       </tbody>
  240.     </xsl:if>
  241.   </table>
  242. </xsl:template>
  243.  
  244. <xsl:template match="tgroup/processing-instruction('dbhtml')">
  245.   <xsl:variable name="summary">
  246.     <xsl:call-template name="dbhtml-attribute">
  247.       <xsl:with-param name="pis" select="."/>
  248.       <xsl:with-param name="attribute" select="'table-summary'"/>
  249.     </xsl:call-template>
  250.   </xsl:variable>
  251.  
  252.   <!-- Suppress the table-summary PI -->
  253.   <xsl:if test="$summary = ''">
  254.     <xsl:processing-instruction name="dbhtml">
  255.       <xsl:value-of select="."/>
  256.     </xsl:processing-instruction>
  257.   </xsl:if>
  258. </xsl:template>
  259.  
  260. <xsl:template match="colspec"></xsl:template>
  261.  
  262. <xsl:template match="spanspec"></xsl:template>
  263.  
  264. <xsl:template match="thead|tfoot">
  265.   <xsl:element name="{name(.)}">
  266.     <xsl:if test="@align">
  267.       <xsl:attribute name="align">
  268.         <xsl:value-of select="@align"/>
  269.       </xsl:attribute>
  270.     </xsl:if>
  271.     <xsl:if test="@char">
  272.       <xsl:attribute name="char">
  273.         <xsl:value-of select="@char"/>
  274.       </xsl:attribute>
  275.     </xsl:if>
  276.     <xsl:if test="@charoff">
  277.       <xsl:attribute name="charoff">
  278.         <xsl:value-of select="@charoff"/>
  279.       </xsl:attribute>
  280.     </xsl:if>
  281.     <xsl:if test="@valign">
  282.       <xsl:attribute name="valign">
  283.         <xsl:value-of select="@valign"/>
  284.       </xsl:attribute>
  285.     </xsl:if>
  286.  
  287.     <xsl:apply-templates select="row[1]">
  288.       <xsl:with-param name="spans">
  289.         <xsl:call-template name="blank.spans">
  290.           <xsl:with-param name="cols" select="../@cols"/>
  291.         </xsl:call-template>
  292.       </xsl:with-param>
  293.     </xsl:apply-templates>
  294.  
  295.   </xsl:element>
  296. </xsl:template>
  297.  
  298. <xsl:template match="tbody">
  299.   <tbody>
  300.     <xsl:if test="@align">
  301.       <xsl:attribute name="align">
  302.         <xsl:value-of select="@align"/>
  303.       </xsl:attribute>
  304.     </xsl:if>
  305.     <xsl:if test="@char">
  306.       <xsl:attribute name="char">
  307.         <xsl:value-of select="@char"/>
  308.       </xsl:attribute>
  309.     </xsl:if>
  310.     <xsl:if test="@charoff">
  311.       <xsl:attribute name="charoff">
  312.         <xsl:value-of select="@charoff"/>
  313.       </xsl:attribute>
  314.     </xsl:if>
  315.     <xsl:if test="@valign">
  316.       <xsl:attribute name="valign">
  317.         <xsl:value-of select="@valign"/>
  318.       </xsl:attribute>
  319.     </xsl:if>
  320.  
  321.     <xsl:apply-templates select="row[1]">
  322.       <xsl:with-param name="spans">
  323.         <xsl:call-template name="blank.spans">
  324.           <xsl:with-param name="cols" select="../@cols"/>
  325.         </xsl:call-template>
  326.       </xsl:with-param>
  327.     </xsl:apply-templates>
  328.  
  329.   </tbody>
  330. </xsl:template>
  331.  
  332. <xsl:template match="row">
  333.   <xsl:param name="spans"/>
  334.  
  335.   <tr>
  336.     <xsl:if test="$table.borders.with.css != 0">
  337.       <xsl:if test="@rowsep = 1">
  338.         <xsl:attribute name="style">
  339.           <xsl:call-template name="border">
  340.             <xsl:with-param name="side" select="'bottom'"/>
  341.           </xsl:call-template>
  342.         </xsl:attribute>
  343.       </xsl:if>
  344.     </xsl:if>
  345.  
  346.     <xsl:if test="@align">
  347.       <xsl:attribute name="align">
  348.         <xsl:value-of select="@align"/>
  349.       </xsl:attribute>
  350.     </xsl:if>
  351.     <xsl:if test="@char">
  352.       <xsl:attribute name="char">
  353.         <xsl:value-of select="@char"/>
  354.       </xsl:attribute>
  355.     </xsl:if>
  356.     <xsl:if test="@charoff">
  357.       <xsl:attribute name="charoff">
  358.         <xsl:value-of select="@charoff"/>
  359.       </xsl:attribute>
  360.     </xsl:if>
  361.     <xsl:if test="@valign">
  362.       <xsl:attribute name="valign">
  363.         <xsl:value-of select="@valign"/>
  364.       </xsl:attribute>
  365.     </xsl:if>
  366.  
  367.     <xsl:apply-templates select="entry[1]">
  368.       <xsl:with-param name="spans" select="$spans"/>
  369.     </xsl:apply-templates>
  370.   </tr>
  371.  
  372.   <xsl:if test="following-sibling::row">
  373.     <xsl:variable name="nextspans">
  374.       <xsl:apply-templates select="entry[1]" mode="span">
  375.         <xsl:with-param name="spans" select="$spans"/>
  376.       </xsl:apply-templates>
  377.     </xsl:variable>
  378.  
  379.     <xsl:apply-templates select="following-sibling::row[1]">
  380.       <xsl:with-param name="spans" select="$nextspans"/>
  381.     </xsl:apply-templates>
  382.   </xsl:if>
  383. </xsl:template>
  384.  
  385. <xsl:template match="entry" name="entry">
  386.   <xsl:param name="col" select="1"/>
  387.   <xsl:param name="spans"/>
  388.  
  389.   <xsl:variable name="cellgi">
  390.     <xsl:choose>
  391.       <xsl:when test="ancestor::thead">th</xsl:when>
  392.       <xsl:when test="ancestor::tfoot">th</xsl:when>
  393.       <xsl:otherwise>td</xsl:otherwise>
  394.     </xsl:choose>
  395.   </xsl:variable>
  396.  
  397.   <xsl:variable name="empty.cell" select="count(node()) = 0"/>
  398.  
  399.   <xsl:variable name="named.colnum">
  400.     <xsl:call-template name="entry.colnum"/>
  401.   </xsl:variable>
  402.  
  403.   <xsl:variable name="entry.colnum">
  404.     <xsl:choose>
  405.       <xsl:when test="$named.colnum > 0">
  406.         <xsl:value-of select="$named.colnum"/>
  407.       </xsl:when>
  408.       <xsl:otherwise>
  409.         <xsl:value-of select="$col"/>
  410.       </xsl:otherwise>
  411.     </xsl:choose>
  412.   </xsl:variable>
  413.  
  414.   <xsl:variable name="entry.colspan">
  415.     <xsl:choose>
  416.       <xsl:when test="@spanname or @namest">
  417.         <xsl:call-template name="calculate.colspan"/>
  418.       </xsl:when>
  419.       <xsl:otherwise>1</xsl:otherwise>
  420.     </xsl:choose>
  421.   </xsl:variable>
  422.  
  423.   <xsl:variable name="following.spans">
  424.     <xsl:call-template name="calculate.following.spans">
  425.       <xsl:with-param name="colspan" select="$entry.colspan"/>
  426.       <xsl:with-param name="spans" select="$spans"/>
  427.     </xsl:call-template>
  428.   </xsl:variable>
  429.  
  430.   <xsl:variable name="rowsep">
  431.     <xsl:call-template name="inherited.table.attribute">
  432.       <xsl:with-param name="entry" select="."/>
  433.       <xsl:with-param name="colnum" select="$entry.colnum"/>
  434.       <xsl:with-param name="attribute" select="'rowsep'"/>
  435.     </xsl:call-template>
  436.   </xsl:variable>
  437.  
  438.   <xsl:variable name="colsep">
  439.     <xsl:call-template name="inherited.table.attribute">
  440.       <xsl:with-param name="entry" select="."/>
  441.       <xsl:with-param name="colnum" select="$entry.colnum"/>
  442.       <xsl:with-param name="attribute" select="'colsep'"/>
  443.     </xsl:call-template>
  444.   </xsl:variable>
  445.  
  446.   <xsl:variable name="valign">
  447.     <xsl:call-template name="inherited.table.attribute">
  448.       <xsl:with-param name="entry" select="."/>
  449.       <xsl:with-param name="colnum" select="$entry.colnum"/>
  450.       <xsl:with-param name="attribute" select="'valign'"/>
  451.     </xsl:call-template>
  452.   </xsl:variable>
  453.  
  454.   <xsl:variable name="align">
  455.     <xsl:call-template name="inherited.table.attribute">
  456.       <xsl:with-param name="entry" select="."/>
  457.       <xsl:with-param name="colnum" select="$entry.colnum"/>
  458.       <xsl:with-param name="attribute" select="'align'"/>
  459.     </xsl:call-template>
  460.   </xsl:variable>
  461.  
  462.   <xsl:variable name="char">
  463.     <xsl:call-template name="inherited.table.attribute">
  464.       <xsl:with-param name="entry" select="."/>
  465.       <xsl:with-param name="colnum" select="$entry.colnum"/>
  466.       <xsl:with-param name="attribute" select="'char'"/>
  467.     </xsl:call-template>
  468.   </xsl:variable>
  469.  
  470.   <xsl:variable name="charoff">
  471.     <xsl:call-template name="inherited.table.attribute">
  472.       <xsl:with-param name="entry" select="."/>
  473.       <xsl:with-param name="colnum" select="$entry.colnum"/>
  474.       <xsl:with-param name="attribute" select="'charoff'"/>
  475.     </xsl:call-template>
  476.   </xsl:variable>
  477.  
  478.   <xsl:choose>
  479.     <xsl:when test="$spans != '' and not(starts-with($spans,'0:'))">
  480.       <xsl:call-template name="entry">
  481.         <xsl:with-param name="col" select="$col+1"/>
  482.         <xsl:with-param name="spans" select="substring-after($spans,':')"/>
  483.       </xsl:call-template>
  484.     </xsl:when>
  485.  
  486.     <xsl:when test="$entry.colnum > $col">
  487.       <xsl:call-template name="empty.table.cell"/>
  488.       <xsl:call-template name="entry">
  489.         <xsl:with-param name="col" select="$col+1"/>
  490.         <xsl:with-param name="spans" select="substring-after($spans,':')"/>
  491.       </xsl:call-template>
  492.     </xsl:when>
  493.  
  494.     <xsl:otherwise>
  495.       <xsl:element name="{$cellgi}">
  496.         <xsl:if test="$show.revisionflag and @revisionflag">
  497.           <xsl:attribute name="class">
  498.             <xsl:value-of select="@revisionflag"/>
  499.           </xsl:attribute>
  500.         </xsl:if>
  501.  
  502.         <xsl:if test="$table.borders.with.css != 0">
  503.           <xsl:attribute name="style">
  504.             <xsl:if test="$colsep > 0">
  505.               <xsl:call-template name="border">
  506.                 <xsl:with-param name="side" select="'right'"/>
  507.               </xsl:call-template>
  508.             </xsl:if>
  509.             <xsl:if test="$rowsep > 0">
  510.               <xsl:call-template name="border">
  511.                 <xsl:with-param name="side" select="'bottom'"/>
  512.               </xsl:call-template>
  513.             </xsl:if>
  514.           </xsl:attribute>
  515.         </xsl:if>
  516.  
  517.         <xsl:if test="@morerows > 0">
  518.           <xsl:attribute name="rowspan">
  519.             <xsl:value-of select="1+@morerows"/>
  520.           </xsl:attribute>
  521.         </xsl:if>
  522.  
  523.         <xsl:if test="$entry.colspan > 1">
  524.           <xsl:attribute name="colspan">
  525.             <xsl:value-of select="$entry.colspan"/>
  526.           </xsl:attribute>
  527.         </xsl:if>
  528.  
  529.         <xsl:if test="$align != ''">
  530.           <xsl:attribute name="align">
  531.             <xsl:value-of select="$align"/>
  532.           </xsl:attribute>
  533.         </xsl:if>
  534.  
  535.         <xsl:if test="$valign != ''">
  536.           <xsl:attribute name="valign">
  537.             <xsl:value-of select="$valign"/>
  538.           </xsl:attribute>
  539.         </xsl:if>
  540.  
  541.         <xsl:if test="$char != ''">
  542.           <xsl:attribute name="char">
  543.             <xsl:value-of select="$char"/>
  544.           </xsl:attribute>
  545.         </xsl:if>
  546.  
  547.         <xsl:if test="$charoff != ''">
  548.           <xsl:attribute name="charoff">
  549.             <xsl:value-of select="$charoff"/>
  550.           </xsl:attribute>
  551.         </xsl:if>
  552.  
  553.         <xsl:if test="not(preceding-sibling::*) and ancestor::row/@id">
  554.           <xsl:call-template name="anchor">
  555.             <xsl:with-param name="node" select="ancestor::row[1]"/>
  556.           </xsl:call-template>
  557.         </xsl:if>
  558.  
  559.         <xsl:call-template name="anchor"/>
  560.  
  561.         <xsl:choose>
  562.           <xsl:when test="$empty.cell">
  563.             <xsl:text> </xsl:text>
  564.           </xsl:when>
  565.           <xsl:otherwise>
  566.             <xsl:apply-templates/>
  567.           </xsl:otherwise>
  568.         </xsl:choose>
  569.       </xsl:element>
  570.  
  571.       <xsl:choose>
  572.         <xsl:when test="following-sibling::entry">
  573.           <xsl:apply-templates select="following-sibling::entry[1]">
  574.             <xsl:with-param name="col" select="$col+$entry.colspan"/>
  575.             <xsl:with-param name="spans" select="$following.spans"/>
  576.           </xsl:apply-templates>
  577.         </xsl:when>
  578.         <xsl:otherwise>
  579.           <xsl:call-template name="finaltd">
  580.             <xsl:with-param name="spans" select="$following.spans"/>
  581.             <xsl:with-param name="col" select="$col+$entry.colspan"/>
  582.           </xsl:call-template>
  583.         </xsl:otherwise>
  584.       </xsl:choose>
  585.     </xsl:otherwise>
  586.   </xsl:choose>
  587. </xsl:template>
  588.  
  589. <xsl:template match="entry" name="sentry" mode="span">
  590.   <xsl:param name="col" select="1"/>
  591.   <xsl:param name="spans"/>
  592.  
  593.   <xsl:variable name="entry.colnum">
  594.     <xsl:call-template name="entry.colnum"/>
  595.   </xsl:variable>
  596.  
  597.   <xsl:variable name="entry.colspan">
  598.     <xsl:choose>
  599.       <xsl:when test="@spanname or @namest">
  600.         <xsl:call-template name="calculate.colspan"/>
  601.       </xsl:when>
  602.       <xsl:otherwise>1</xsl:otherwise>
  603.     </xsl:choose>
  604.   </xsl:variable>
  605.  
  606.   <xsl:variable name="following.spans">
  607.     <xsl:call-template name="calculate.following.spans">
  608.       <xsl:with-param name="colspan" select="$entry.colspan"/>
  609.       <xsl:with-param name="spans" select="$spans"/>
  610.     </xsl:call-template>
  611.   </xsl:variable>
  612.  
  613.   <xsl:choose>
  614.     <xsl:when test="$spans != '' and not(starts-with($spans,'0:'))">
  615.       <xsl:value-of select="substring-before($spans,':')-1"/>
  616.       <xsl:text>:</xsl:text>
  617.       <xsl:call-template name="sentry">
  618.         <xsl:with-param name="col" select="$col+1"/>
  619.         <xsl:with-param name="spans" select="substring-after($spans,':')"/>
  620.       </xsl:call-template>
  621.     </xsl:when>
  622.  
  623.     <xsl:when test="$entry.colnum > $col">
  624.       <xsl:text>0:</xsl:text>
  625.       <xsl:call-template name="sentry">
  626.         <xsl:with-param name="col" select="$col+$entry.colspan"/>
  627.         <xsl:with-param name="spans" select="$following.spans"/>
  628.       </xsl:call-template>
  629.     </xsl:when>
  630.  
  631.     <xsl:otherwise>
  632.       <xsl:call-template name="copy-string">
  633.         <xsl:with-param name="count" select="$entry.colspan"/>
  634.         <xsl:with-param name="string">
  635.           <xsl:choose>
  636.             <xsl:when test="@morerows">
  637.               <xsl:value-of select="@morerows"/>
  638.             </xsl:when>
  639.             <xsl:otherwise>0</xsl:otherwise>
  640.           </xsl:choose>
  641.           <xsl:text>:</xsl:text>
  642.         </xsl:with-param>
  643.       </xsl:call-template>
  644.  
  645.       <xsl:choose>
  646.         <xsl:when test="following-sibling::entry">
  647.           <xsl:apply-templates select="following-sibling::entry[1]"
  648.                                mode="span">
  649.             <xsl:with-param name="col" select="$col+$entry.colspan"/>
  650.             <xsl:with-param name="spans" select="$following.spans"/>
  651.           </xsl:apply-templates>
  652.         </xsl:when>
  653.         <xsl:otherwise>
  654.           <xsl:call-template name="sfinaltd">
  655.             <xsl:with-param name="spans" select="$following.spans"/>
  656.           </xsl:call-template>
  657.         </xsl:otherwise>
  658.       </xsl:choose>
  659.     </xsl:otherwise>
  660.   </xsl:choose>
  661. </xsl:template>
  662.  
  663. <xsl:template name="generate.colgroup">
  664.   <xsl:param name="cols" select="1"/>
  665.   <xsl:param name="count" select="1"/>
  666.   <xsl:choose>
  667.     <xsl:when test="$count > $cols"></xsl:when>
  668.     <xsl:otherwise>
  669.       <xsl:call-template name="generate.col">
  670.         <xsl:with-param name="countcol" select="$count"/>
  671.       </xsl:call-template>
  672.       <xsl:call-template name="generate.colgroup">
  673.         <xsl:with-param name="cols" select="$cols"/>
  674.         <xsl:with-param name="count" select="$count+1"/>
  675.       </xsl:call-template>
  676.     </xsl:otherwise>
  677.   </xsl:choose>
  678. </xsl:template>
  679.  
  680. <xsl:template name="generate.col">
  681.   <xsl:param name="countcol">1</xsl:param>
  682.   <xsl:param name="colspecs" select="./colspec"/>
  683.   <xsl:param name="count">1</xsl:param>
  684.   <xsl:param name="colnum">1</xsl:param>
  685.  
  686.   <xsl:choose>
  687.     <xsl:when test="$count>count($colspecs)">
  688.       <col/>
  689.     </xsl:when>
  690.     <xsl:otherwise>
  691.       <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
  692.       <xsl:variable name="colspec.colnum">
  693.         <xsl:choose>
  694.           <xsl:when test="$colspec/@colnum">
  695.             <xsl:value-of select="$colspec/@colnum"/>
  696.           </xsl:when>
  697.           <xsl:otherwise>
  698.             <xsl:value-of select="$colnum"/>
  699.           </xsl:otherwise>
  700.         </xsl:choose>
  701.       </xsl:variable>
  702.  
  703.       <xsl:choose>
  704.         <xsl:when test="$colspec.colnum=$countcol">
  705.           <col>
  706.             <xsl:if test="$colspec/@colwidth
  707.                           and $use.extensions != 0
  708.                           and $tablecolumns.extension != 0">
  709.               <xsl:attribute name="width">
  710.                 <xsl:value-of select="$colspec/@colwidth"/>
  711.               </xsl:attribute>
  712.             </xsl:if>
  713.  
  714.             <xsl:choose>
  715.               <xsl:when test="$colspec/@align">
  716.                 <xsl:attribute name="align">
  717.                   <xsl:value-of select="$colspec/@align"/>
  718.                 </xsl:attribute>
  719.               </xsl:when>
  720.               <!-- Suggested by Pavel ZAMPACH <zampach@nemcb.cz> -->
  721.               <xsl:when test="$colspecs/ancestor::tgroup/@align">
  722.                 <xsl:attribute name="align">
  723.                   <xsl:value-of select="$colspecs/ancestor::tgroup/@align"/>
  724.                 </xsl:attribute>
  725.               </xsl:when>
  726.             </xsl:choose>
  727.  
  728.             <xsl:if test="$colspec/@char">
  729.               <xsl:attribute name="char">
  730.                 <xsl:value-of select="$colspec/@char"/>
  731.               </xsl:attribute>
  732.             </xsl:if>
  733.             <xsl:if test="$colspec/@charoff">
  734.               <xsl:attribute name="charoff">
  735.                 <xsl:value-of select="$colspec/@charoff"/>
  736.               </xsl:attribute>
  737.             </xsl:if>
  738.           </col>
  739.         </xsl:when>
  740.         <xsl:otherwise>
  741.           <xsl:call-template name="generate.col">
  742.             <xsl:with-param name="countcol" select="$countcol"/>
  743.             <xsl:with-param name="colspecs" select="$colspecs"/>
  744.             <xsl:with-param name="count" select="$count+1"/>
  745.             <xsl:with-param name="colnum">
  746.               <xsl:choose>
  747.                 <xsl:when test="$colspec/@colnum">
  748.                   <xsl:value-of select="$colspec/@colnum + 1"/>
  749.                 </xsl:when>
  750.                 <xsl:otherwise>
  751.                   <xsl:value-of select="$colnum + 1"/>
  752.                 </xsl:otherwise>
  753.               </xsl:choose>
  754.             </xsl:with-param>
  755.            </xsl:call-template>
  756.         </xsl:otherwise>
  757.       </xsl:choose>
  758.     </xsl:otherwise>
  759.   </xsl:choose>
  760.  
  761. </xsl:template>
  762.  
  763. <xsl:template name="colspec.colwidth">
  764.   <!-- when this macro is called, the current context must be an entry -->
  765.   <xsl:param name="colname"></xsl:param>
  766.   <!-- .. = row, ../.. = thead|tbody, ../../.. = tgroup -->
  767.   <xsl:param name="colspecs" select="../../../../tgroup/colspec"/>
  768.   <xsl:param name="count">1</xsl:param>
  769.   <xsl:choose>
  770.     <xsl:when test="$count>count($colspecs)"></xsl:when>
  771.     <xsl:otherwise>
  772.       <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
  773.       <xsl:choose>
  774.         <xsl:when test="$colspec/@colname=$colname">
  775.           <xsl:value-of select="$colspec/@colwidth"/>
  776.         </xsl:when>
  777.         <xsl:otherwise>
  778.           <xsl:call-template name="colspec.colwidth">
  779.             <xsl:with-param name="colname" select="$colname"/>
  780.             <xsl:with-param name="colspecs" select="$colspecs"/>
  781.             <xsl:with-param name="count" select="$count+1"/>
  782.           </xsl:call-template>
  783.         </xsl:otherwise>
  784.       </xsl:choose>
  785.     </xsl:otherwise>
  786.   </xsl:choose>
  787. </xsl:template>
  788.  
  789. </xsl:stylesheet>
  790.  
  791. This resource fork intentionally left blank   ˇˇ